home *** CD-ROM | disk | FTP | other *** search
- /*
- * ARTA VUMeters for Macintosh
- * Malcolm Slaney
- * Advanced Technology Group
- * Apple Computer, Inc.
- * malcolm@apple.com
- * 1992-1993
- *
- * Warranty Information
- * Even though Apple has reviewed this software, Apple makes no warranty
- * or representation, either express or implied, with respect to this
- * software, its quality, accuracy, merchantability, or fitness for a
- * particular purpose. As a result, this software is provided "as is,"
- * and you, its user, are assuming the entire risk as to its quality
- * and accuracy.
- *
- * Copyright (c) 1992-1993 by Apple Computer, Inc
- * All Rights Reserved.
- */
- #include <QDOffscreen.h>
- #include <Picker.h>
-
- #define NIL_POINTER (void *)0
- #define NO_FLAGS 0L
- #define NULL_STRING "\p"
- #define NIL_STRING "\p"
- #define MOVE_TO_FRONT -1L
- #define SCROLL_BAR_SIZE 15
- #define REMOVE_ALL_EVENTS 0
- #define MIN_SLEEP 0L
- #define NIL_MOUSE_REGION 0L
- #define DRAG_THRESHOLD 30
-
- #define LEAVE_WHERE_IT_IS FALSE
- #define NORMAL_UPDATES TRUE
-
- #define SCALE_FONT_NUMBER 1 /* Font for labeling meter */
- #define SCALE_FONT_SIZE 9 /* Font size for meter label */
- #define SCALE_DEGREES 150 /* Total angle of scale travel */
- #define SCALE_OVERLOAD_DELTA 10 /* Offset from corner for light */
- #define SCALE_OVERLOAD_SIZE 5 /* Size of indicator */
-
- #define DEFAULT_SCREEN_DEPTH 0 /* Set to 0 so NewGWorld will pick best */
-
- /* As a percentage of needle length */
- const float kTickStart = .9; /* Inner Radius of ticks */
- const float kTickMiddle = .95; /* For Short Ticks */
- const float kTickEnd = 1.0; /* Outer Radius */
-
- enum channelNum { kLeftChannel = 0, kRightChannel = 1, kMaxChannel = 2, kBothChannel};
- enum portNum {kInputPort = 0, kOutputPort = 1};
- enum levelNum {kPeakReading = 0, kPowerReading = 1};
- enum speedNum {kFastSpeed = 0, kNormalSpeed = 1};
- enum referenceNum {kFullScaleReference = 0, kAnalogLineReference = 1};
-
- /* A generic piece of a window with
- * its own offscreen GWorld and a
- * rect to tell me where to put it.
- */
- class CWindowPiece {
- protected:
- GWorldPtr fOffScreenWorld;
- Rect fWindowRect;
- WindowPtr fWindow;
- RgnHandle fDirtyScreenRegion; /* Portion of screen that needs updating */
-
- public:
- void IWindowPiece();
- void CopyToWindow();
- void Erase();
- void SetWindowRect(Rect *screenRect, Rect *windowRect);
- void SetWindow(WindowPtr);
- void Update();
- void Dispose();
- };
-
- /* One VU Meter. This is actually
- * implemented as a CWindowPiece so
- * this class tells how to draw the
- * background scale into an offscreen
- * bitmap and how to copy the scale and
- * the needle into the window. A window
- * that is showing two VU meters will
- * have two instances of this class.
- */
- class CVUMeter: public CWindowPiece {
- protected:
- float fLastReading;
- float *fCurrentReading; /* Pointer to left and right readings */
- float *fChannelGainPointer; /* External gain factor to include */
- GWorldPtr fScaleWorld;
- Point fMeterCenter;
- int fScaleLength; /* Computed by SetWindowRect() */
- enum channelNum fChannelIndicator;
- enum portNum fPortType;
- enum levelNum fLevelType;
- enum speedNum fSpeedType;
- enum referenceNum fReferenceType;
- RgnHandle fDirtyScaleRegion; /* Portion of scale that needs updating */
- short fOverload; /* Is the overload light lit? */
- Rect fOverloadRect; /* Position of overload light */
-
- public:
- void IVUMeter(enum portNum portType, enum channelNum channelIndicator,
- enum levelNum readingType, enum speedNum speedType,
- enum referenceNum referenceType);
- void SetMeterParms(Rect *windowRect);
- void DrawScale();
- void DrawNeedle();
- void UpdateLevel();
- void RefreshLevel();
- void GetExternalGain();
- void SetWindowRect(Rect *screenRect, Rect *windowRect);
- void Dispose();
- int AllMemoryAllocated();
- };
-
- class CPictureMeter: public CVUMeter {
- private:
- PicHandle fPicture;
- public:
- void IVUMeter(enum portNum portType, enum channelNum channelIndicator,
- enum levelNum readingType, enum speedNum speedType,
- enum referenceNum referenceType);
- void SetMeterParms(Rect *windowRect);
- void DrawScale();
- };
- /* A window showing one or two VU
- * meters corresponding to one point
- * in the signal flow patch bay.
- */
- class CPortWindow {
- protected:
- enum portNum fPortType;
- enum channelNum fChannel;
- enum levelNum fLevelType;
- enum speedNum fSpeedType;
- enum referenceNum fReferenceType;
- CVUMeter *fFirstMeter;
- CVUMeter *fSecondMeter;
- WindowPtr fWindow;
-
- public:
- void IPortWindow();
- void NewWindow();
- void UpdateWindowType();
- void UpdateWindowSize();
- void UpdateLevel();
- void RedrawWindow();
- void RefreshWindow();
- void SetUpMenus();
- void Update();
- void Dispose();
- int AllMemoryAllocated();
- WindowPtr GetWindow();
- };
-
- extern int IsMemoryAvailable(long memoryRequest);
- long MemoryNeededForNewWindow(Rect *screenRect);
- void DoCautionAlert(short messageNumber);
- void DoStopAlert(short messageNumber);
- void ShowValue(short messageNumber, long val);
-
-